package cn.eud.hunau;

import org.junit.Test;

import java.util.Random;

import static org.apache.coyote.http11.Constants.a;

public class ArraySum {
    @Test
    public void testArraySum2(){

        int [] arr={20,21,22,23,24,25};
        int sum =arraySum(arr);
        System.out.println(sum);
    }

    public int arraySum(int[] arr){
        int sum=0;
        for(int i=0;i<arr.length;i++){
            sum+=arr[i];
        }
         return sum;
    }




    @Test
    public void testRandom(){
        Random r=new Random();
        //声明长度为6的int类型的数组，用于存储数据
        int[] arr=new int[6];
        for(int i=0;i<arr.length;i++){
            int num = r.nextInt(33)+1;
            arr[i]=num;
        }

    }











    @Test
    public void test01(){

        int[] arr = {12, 45, 7, 9, 23, 56, 18, 3};
        int sum=0;
        for(int i=0;i<arr.length;i++){
            sum+=arr[i];
        }
        System.out.println(sum);
    }
}
